package portes;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import fbcast.FbCast;

import agrawala.PorteRicartAgrawala;
//import agrawala.PorteRicartAgrawala;

import suzuki.JetonSuzukiKasami;

public class PorteImpl extends UnicastRemoteObject implements Porte{

	/**
	 * 
	 */
	private static final long serialVersionUID = -8693479209681579104L;
	
	private static final int SUZUKIJETON = 1;
	private static final int AGRAWALAHORLOGE = 2;
	private static final int DIFFUSION = 3;
	private Algo algo;
	private int idAttribue;


	public int getIdAttribue() {
		return idAttribue;
	}

	public void setIdAttribue(int idAttribue) {
		this.idAttribue = idAttribue;
	}

	protected PorteImpl(String serveur, int port, int nbrPlaces, int choixAlgo) throws RemoteException {
		super();
		if(choixAlgo == SUZUKIJETON){
			this.algo = new JetonSuzukiKasami(serveur, port, nbrPlaces,this );
		} else if(choixAlgo == AGRAWALAHORLOGE){
			this.algo = new PorteRicartAgrawala(serveur, port, nbrPlaces,this );
		} else if(choixAlgo == DIFFUSION){
			this.algo = new FbCast(serveur, port, nbrPlaces,this );
		}
		
		
	}

	@Override
	public void demandeEntreeDansParking() throws RemoteException {
		algo.demandeEntree();
		
	}

	@Override
	public void demandeSortieDansParking() throws RemoteException {
		algo.demandeSortie();
	}
	
	

}
